Hello all:
I wrote this wrapper that creates either a K-M or a FPM plot with several design specifications that would be repeatable for consistency. The wrapper works perfectly in most instances even with an if clause to subset data (if icc2 == 1 for example below), but for occasional subset of certain variables it hangs with the invalid syntax error r(198) and I cannot decipher why it would do that. When I just write a sts graph outside of the program, it works perfectly. All variables are binary variables and levels seem correct.
I don't see trace picking any error either. If the program works for most variables, the syntax has to be correct otherwise, right? Regardless, there is something in the body of the program that is making it fail.
Any pointers for troubleshooting would be welcome. Glad to share the rest of the 350 odd lines of code and -dataex- if someone has interest, but that would make it very cumbersome for someone to troubleshoot.
Syntax is below with final call to the program after that.
Faulty call that does not run
This works perfectly though with:
I wrote this wrapper that creates either a K-M or a FPM plot with several design specifications that would be repeatable for consistency. The wrapper works perfectly in most instances even with an if clause to subset data (if icc2 == 1 for example below), but for occasional subset of certain variables it hangs with the invalid syntax error r(198) and I cannot decipher why it would do that. When I just write a sts graph outside of the program, it works perfectly. All variables are binary variables and levels seem correct.
I don't see trace picking any error either. If the program works for most variables, the syntax has to be correct otherwise, right? Regardless, there is something in the body of the program that is making it fail.
Any pointers for troubleshooting would be welcome. Glad to share the rest of the 350 odd lines of code and -dataex- if someone has interest, but that would make it very cumbersome for someone to troubleshoot.
Syntax is below with final call to the program after that.
Code:
*! program 1.0.0 grsurv GV 05jan2024 added italics for subtitles too *------------------------------------------------- cap program drop grsurve program define grsurve, sortpreserve version 18 syntax varname(numeric max=1 fv) [if] , /// *Required [plot(string)] /// *plot(km) or plot(fpm) are your options--km if ignored [ciband(string)] /// *Optional CI bands for fpm models [risktable(string)] /// *Optional if KM plot needed TITLE(string) /// SUBTITLE(string) /// [ RELAB0(string) /// RELAB1(string) /// ITAL(string) /// italicize these SUPS(string) /// superscript these SUBS(string) /// subscript these PAN(string)] /// * Panel naming if you want panel for a multipart [SWITCHCOL(string) ] /// * Make top curve navy always (variables where 1 is better prognosis) [SCALE(string asis)] /// [ MYOPTs * ] // varname is called as `varlist' in a program after first instance // MYOPTS is collected in `options' only, not `myopts'; syntax does not have myopt() either marksample touse ... Rest of program----assertions for binaries, sts, km and stpm2- plotting options // .... end
Code:
local rt no
grsurve germline if icc2==0, risktable(`rt') plot(km) ciband(no) ///
title(Impact of germline alt.) subtitle("TP53sh subset") ///
relab0(No Germline alt.) relab1(Germline alt.) sups(sh) subs() ital(TP53 sh) ///
switchcol(no) scale(months) note() name(A, replace)
Code:
sts graph germline if icc2 == 0